// pages/class/classes.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  test:function(e){
    console.log(e)
    var app = getApp();
    var testUrl = app.testUrl;
    var that = this;
    var id = e.currentTarget.dataset.categoryid
    wx.request({
      url: testUrl + '/lesson/search.do?page=1&rows=10',
      method: "post",
      data: { "categoryId": parseInt(id) },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        that.setData({
          lessonList: res.data.rows
        });
        console.log(that.data);
      }
    });

    // wx.redirectTo({
    //   url: '/pages/classList/classlist',
    // })
  },

  toclassList2: function () {

  },


  onLoad: function (options) {
    console.log(options.id)
    var app = getApp();
    var testUrl = app.testUrl;
    var that = this;

    wx.request({
      url: testUrl + '/lesson/search.do?page=1&rows=10',
      method: "post",
      data: { "categoryId": parseInt(options.id) },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        that.setData({
          lessonList: res.data.rows
        });
        console.log("获取推荐课程" + that.data);
      }
    });

    //获取轮播图
    wx.request({
      url: testUrl + '/trollImg/findAll.do',
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        that.setData({
          trollImgList: res.data
        });
        console.log("获取轮播图" + that.data);

      }
    });
    //获取课程分类
    wx.request({
      url: testUrl + '/lessonCategory/findAll.do',
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        that.setData({
          lessonCategoryList: res.data
        });
        console.log("获取课程分类" + that.data);

      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  toVideo:function(){
    wx.navigateTo({
      url: '/pages/video/video',
    })
  },




  onReady: function () {

  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})